#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <sys/time.h>

int main(int argc, char *args[])
{
    int len = 100;
   
    printf("start to get [%d]\n", argc);
    if (argc >= 2) len = atoi(args[1]);
    printf("get len [%d]\n", len);

    char  tt[1000] = {};
    if (len >= 10000) return -1;

    printf("get len [%d]\n", len);
    int i;
    for (i = 0; i < len; i++) {
        tt[i] = 'a';
    }
    tt[len] = '\0';

    printf("start to cal");
    time_t t1, t2;

    t1 = time(NULL);
    struct timeval tv, tv2;
    gettimeofday(&tv, NULL);
    printf("Now time [%ld]\n", tv.tv_usec);
    for (i = 0; i < strlen(tt); i++) {
        t2 = time(NULL);
        gettimeofday(&tv2, NULL);
        time_t inter = tv2.tv_usec - tv.tv_usec;
        printf("t2 [%ld] t1 [%ld], [%d]inter[%ld]\n", tv2.tv_usec, tv.tv_usec, i, inter);
        t1 = time(NULL);
        gettimeofday(&tv, NULL);
    }
    return 0;
}
